﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MVCWeb.Models.TvModel>" %>

<script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                DisplayList.SelectedIndexChanged += new EventHandler(DisplayList_SelectedIndexChanged);
                ShippingList.SelectedIndexChanged += new EventHandler(ShippingList_SelectedIndexChanged);
            }

            void DisplayList_SelectedIndexChanged(object sender, EventArgs e)
            {
                //throw new NotImplementedException();
                //DisplayList.SelectedIndexChanged += new EventHandler(DisplayList_SelectedIndexChanged);
                DisplayLabel.Text = DisplayList.SelectedItem.Value;
            }

            void ShippingList_SelectedIndexChanged(object sender, EventArgs e)
            {
                //throw new NotImplementedException();
                //DisplayList.SelectedIndexChanged += new EventHandler(DisplayList_SelectedIndexChanged);
                DisplayLabel.Text = DisplayList.SelectedItem.Value;
            }
    
    </script>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	TvIndex
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <!--<form id="form1" action="Tv/Search" method="get" runat="server">-->

    <h2>TvIndex</h2>

    <% using (Html.BeginRouteForm("Search")){ %>
    <fieldset>
    
    <p>Choose Display 
        

        <asp:DropDownList ID="DisplayList" runat="server" DataSourceID="Display" EnableViewState="true" OnSelectedIndexChanged="DisplayList_SelectedIndexChanged" AutoPostBack="true"
                DataTextField="display_type" DataValueField="display_id">
                </asp:DropDownList>

        <asp:SqlDataSource ID="Display" runat="server" 
                ConnectionString="<%$ ConnectionStrings:cse136ConnectionString %>" 
                SelectCommand="SELECT * FROM [Display]"></asp:SqlDataSource>
        
        <asp:Label ID="DisplayLabel" runat="server"></asp:Label>      
        </p>        
            
    <p>Choose Make <asp:DropDownList ID="MakeList" runat="server" DataSourceID="Make" 
                DataTextField="make" DataValueField="make_id">
                </asp:DropDownList>

            <asp:SqlDataSource ID="Make" runat="server" 
                ConnectionString="<%$ ConnectionStrings:cse136ConnectionString %>" 
                SelectCommand="SELECT * FROM [Make]"></asp:SqlDataSource></p>
           
    <p>Choose Size <asp:DropDownList ID="SizeList" runat="server" 
                DataSourceID="Size" DataTextField="size" DataValueField="size_id">
            </asp:DropDownList>

            <asp:SqlDataSource ID="Size" runat="server" 
                ConnectionString="<%$ ConnectionStrings:cse136ConnectionString %>" 
                SelectCommand="SELECT * FROM [Size]"></asp:SqlDataSource></p>
            

    <p>Choose Resolution <asp:DropDownList ID="ResolutionList" runat="server" 
                DataSourceID="Resolution" DataTextField="resolution" 
            DataValueField="res_id">
            </asp:DropDownList>
            
            <asp:SqlDataSource ID="Resolution" runat="server" 
                ConnectionString="<%$ ConnectionStrings:cse136ConnectionString %>" 
                SelectCommand="SELECT * FROM [Resolution]"></asp:SqlDataSource></p>            


        <p>Choose Refresh<asp:DropDownList ID="RefreshList" runat="server" 
                DataSourceID="Refresh" DataTextField="refresh_rate" 
            DataValueField="refresh_id">
            </asp:DropDownList>

            <asp:SqlDataSource ID="Refresh" runat="server" 
                ConnectionString="<%$ ConnectionStrings:cse136ConnectionString %>" 
                SelectCommand="SELECT * FROM [Refresh]"></asp:SqlDataSource></p>

           

    <p>Choose Shipping <asp:DropDownList ID="ShippingList" runat="server" EnableViewState="true" OnSelectedIndexChanged="ShippingList_SelectedIndexChanged" AutoPostBack="true">
                <asp:ListItem Value="0">No Free Shipping</asp:ListItem>
                <asp:ListItem Value="1" Selected="True">Free Shipping Available</asp:ListItem>
            </asp:DropDownList></p>  
     
    </fieldset>

    <%= Html.ActionLink("Search","Search", 
        new { 
            display = DisplayList.SelectedItem.Value,
            make = MakeList.SelectedItem.Value,
            size = SizeList.SelectedItem.Value,
            res = ResolutionList.SelectedItem.Value,
            refresh = RefreshList.SelectedItem.Value,
            shipping = ShippingList.SelectedItem.Value
            })%>
    
    <!--<asp:Button id="submit" runat="server" text="Search" />-->

    

    <% } %>
    <!--</form>-->
</asp:Content>